<template>
  <div>
    <ul>
      <li v-for="message in messages" :key="message.id">
        <router-link :to="`/home/message/detail/${message.id}`">{{message.title}}</router-link>
        <button @click="push(message.id)">push查看</button>
        <button @click="replace(message.id)">replace查看</button>
      </li>
      <button @click="$router.back()">回退</button>
    </ul>
    <hr>
    <router-view/>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        messages: []
      }
    },
    mounted () {
      setTimeout(() => {
        this.messages = [
          {
            id: 2,
            title: 'message02'
          },
          {
            id: 4,
            title: 'message04'
          },
          {
            id: 6,
            title: 'message06'
          }
        ]
      }, 1000)
    },
    methods: {
      push (id) {
        this.$router.push(`/home/message/detail/${id}`)
      },
      replace (id) {
        this.$router.replace(`/home/message/detail/${id}`)
      }
    }
  }
</script>

<style>

</style>
